import pygame
import sys

class Graphics(object):

  def __init__(self, screen):
    self.__screen = screen
    self.__stack = []
    self.__coord = [0, 0]

  def drawImage(self, img, coord, clip=None):
    self.drawSurface(img.getSurface(), coord, clip)

  def drawSurface(self, s, coord, clip=None):
    coord[0] += self.__coord[0]
    coord[1] += self.__coord[1]

    if coord[0] + s.get_width() > 0 and coord[0] < self.__screen.get_width():
      if coord[1] + s.get_height() > 0 and coord[1] < self.__screen.get_height():
        self.__screen.blit(s, coord, clip)

  def clearScreen(self):
    self.__screen.fill((0, 0, 0))

  def pushScreen(self, x, y):
    self.__stack.append([x, y])
    self.__coord[0] += x
    self.__coord[1] += y

  def popScreen(self):
    coords = self.__stack.pop()
    self.__coord[0] -= coords[0]
    self.__coord[1] -= coords[1]

  def getScreenSize(self):
    return (self.__screen.get_width(), self.__screen.get_height())
